﻿@model OrderDetailsModel
@using Nop.Web.Models.Order;
@{
    Layout = "~/Views/Shared/_Root.cshtml";
    //title
    Html.AddTitleParts(T("PageTitle.OrderDetails").Text);
}
<div class="page order-details-page">
    <div class="page-title">
        <h1>
            @T("Order.OrderInformation")</h1>
    </div>
    <div class="page-body">
        @Html.Widget("mobile_orderdetails_page_top")
        <div class="order-overview">
            <div>
                <strong>@T("Order.Order#")@Model.Id</strong>
            </div>
            <div>
                @T("Order.OrderDate"): @Model.CreatedOn.ToString("D")
            </div>
            <div>
                @T("Order.OrderTotal"): @Model.OrderTotal
            </div>
            <div>
                @T("Order.OrderStatus"): @Model.OrderStatus
            </div>
            @Html.Widget("mobile_orderdetails_page_overview")
        </div>
        <div class="order-details-box">
            <div class="billing-info">
                <div class="title">
                    <strong>
                        @T("Order.BillingAddress")</strong>
                </div>
                <div class="name">@Model.BillingAddress.FirstName @Model.BillingAddress.LastName</div>
                <div class="email">
                    @T("Order.Email"): @Model.BillingAddress.Email
                </div>
                @if (Model.BillingAddress.PhoneEnabled)
                {
                    <div class="phone">
                        @T("Order.Phone"): @Model.BillingAddress.PhoneNumber
                    </div>
                }
                @if (Model.BillingAddress.FaxEnabled)
                {
                    <div class="fax">
                        @T("Order.Fax"): @Model.BillingAddress.FaxNumber
                    </div>
                }
                @if (Model.BillingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.BillingAddress.Company))
                {
                    <div class="company">
                        @Model.BillingAddress.Company
                    </div>
                }
                @if (Model.BillingAddress.StreetAddressEnabled)
                {
                    <div class="address1">
                        @Model.BillingAddress.Address1
                    </div>
                }
                @if (Model.BillingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.BillingAddress.Address2))
                {
                    <div class="address2">
                        @Model.BillingAddress.Address2
                    </div>
                }
                @if (Model.BillingAddress.CityEnabled ||
                            Model.BillingAddress.StateProvinceEnabled ||
                            Model.BillingAddress.ZipPostalCodeEnabled)
                {
                    <div class="city-state-zip">
                        @if (Model.BillingAddress.CityEnabled)
                        {
                            @Model.BillingAddress.City
                        }
                        @if (Model.BillingAddress.CityEnabled && (Model.BillingAddress.StateProvinceEnabled || Model.BillingAddress.ZipPostalCodeEnabled))
                        {
                            <text>,</text>
                        }
                        @if (Model.BillingAddress.StateProvinceEnabled)
                        {
                            @Model.BillingAddress.StateProvinceName
                        }
                        @if (Model.BillingAddress.ZipPostalCodeEnabled)
                        {
                            @Model.BillingAddress.ZipPostalCode
                        }
                    </div>
                }
                @if (Model.BillingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.BillingAddress.CountryName))
                {
                    <div class="country">
                        @Model.BillingAddress.CountryName
                    </div>
                }
                @if (!String.IsNullOrEmpty(Model.VatNumber))
                {
                    <div class="vat">
                        <div class="vat-label">
                            <strong>@T("Order.VATNumber")</strong>
                        </div>
                        <div class="vat-value">
                            @Model.VatNumber
                        </div>
                    </div>
                }
                @if (!String.IsNullOrEmpty(Model.PaymentMethod))
                {
                    <div class="payment-method">
                        <div class="payment-method-label">
                            <strong>@T("Order.PaymentMethod")</strong>
                        </div>
                        <div class="payment-method-value">
                            @Model.PaymentMethod
                        </div>
                    </div>
                    if (Model.CanRePostProcessPayment)
                    {
@*Completing payment support (for redirection payment methods)*
                            @*set "data-ajax" attribute to "false"*@
                    <div class="repost">
                        @using (Html.BeginRouteForm("OrderDetails", FormMethod.Post,
                                new Dictionary<string, Object> { { "data-ajax", "false" } }))
                        {
                            <input type="submit" name="repost-payment" value="@T("Order.RetryPayment")" />
                            <p class="hint">
                                <em>@T("Order.RetryPayment.Hint")</em>
                            </p>
                        }
                    </div>
                    }
                }
                @if (Model.DisplayPurchaseOrderNumber)
                {
                    <div class="po">
                        <div class="po-label">
                            <strong>@T("Order.PurchaseOrderNumber")</strong>
                        </div>
                        <div class="po-value">
                            @Model.PurchaseOrderNumber
                        </div>
                    </div>
                }
            </div>
            @if (Model.IsShippable)
            {
                <div class="shipping-info">
                    <div class="title">
                        <strong>@T("Order.ShippingAddress")</strong>
                    </div>
                    <div class="name">
                        @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName
                    </div>
                    <div class="email">
                        @T("Order.Email"): @Model.ShippingAddress.Email
                    </div>
                    @if (Model.ShippingAddress.PhoneEnabled)
                    {
                        <div class="phone">
                            @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber
                        </div>
                    }
                    @if (Model.ShippingAddress.FaxEnabled)
                    {
                        <div class="fax">
                            @T("Order.Fax"): @Model.ShippingAddress.FaxNumber
                        </div>
                    }
                    @if (Model.ShippingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.Company))
                    {
                        <div class="company">
                            @Model.ShippingAddress.Company
                        </div>
                    }
                    @if (Model.ShippingAddress.StreetAddressEnabled)
                    {
                        <div class="address1">
                            @Model.ShippingAddress.Address1
                        </div>
                    }
                    @if (Model.ShippingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.ShippingAddress.Address2))
                    {
                        <div class="address2">
                            @Model.ShippingAddress.Address2
                        </div>
                    }
                    @if (Model.ShippingAddress.CityEnabled ||
                            Model.ShippingAddress.StateProvinceEnabled ||
                            Model.ShippingAddress.ZipPostalCodeEnabled)
                    {
                        <div class="city-state-zip">
                            @if (Model.ShippingAddress.CityEnabled)
                            {
                                @Model.ShippingAddress.City
                            }
                            @if (Model.ShippingAddress.CityEnabled && (Model.ShippingAddress.StateProvinceEnabled || Model.ShippingAddress.ZipPostalCodeEnabled))
                            {
                                <text>,</text>
                            }
                            @if (Model.ShippingAddress.StateProvinceEnabled)
                            {
                                @Model.ShippingAddress.StateProvinceName
                            }
                            @if (Model.ShippingAddress.ZipPostalCodeEnabled)
                            {
                                @Model.ShippingAddress.ZipPostalCode
                            }
                        </div>
                    }
                    @if (Model.ShippingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
                    {
                        <div class="country">
                            @Model.ShippingAddress.CountryName
                        </div>
                    }
                    <div class="shipping-method">
                        <div class="shipping-method-label">
                            <strong>@T("Order.ShippingMethod")</strong>
                        </div>
                        <div class="shipping-method-value">
                            @Model.ShippingMethod
                        </div>
                    </div>
                </div>
            }
        </div>
        @Html.Widget("mobile_orderdetails_page_beforeproducts")
        @if (Model.Items.Count > 0)
        {
            <div class="section-title">
                @T("Order.Product(s)")
            </div>
            <ul data-role="listview" data-inset="true" data-filter="false" data-theme="c">
                @foreach (var item in Model.Items)
                {
                    <li>
                        <div class="products-box">
                            <div class="product">
                                <strong><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></strong>
                                @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                {
                                    <div class="attributes">
                                        @Html.Raw(item.AttributeInfo)
                                    </div>
                                }
                            </div>
                            @if (Model.ShowSku && !string.IsNullOrEmpty(item.Sku))
                            {
                                <div class="sku">
                                    @T("Order.Product(s).SKU"): @item.Sku
                                </div>
                            }
                            <div class="unitprice">
                                @T("Order.Product(s).Price"): @item.UnitPrice
                            </div>
                            <div class="qty">
                                @T("Order.Product(s).Quantity"): @item.Quantity
                            </div>
                            <div class="subtotal">
                                @T("Order.Product(s).Total"): @item.SubTotal
                            </div>
                        </div>
                    </li>
                }
            </ul>
                if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                {
            <div class="checkout-attributes">
                @Html.Raw(Model.CheckoutAttributeInfo)
            </div>
                }
@*Reorder support*@
                if (Model.IsReOrderAllowed)
                {
            <a href="@Url.RouteUrl("ReOrder", new { orderId = Model.Id })" data-role="button">@T("Order.Reorder")</a>
                }
                if (Model.IsReturnRequestAllowed)
                {
            <a href="@Url.RouteUrl("ReturnRequest", new { orderId = Model.Id })" data-role="button">@T("Order.ReturnItems")</a>
                }
        }
        @Html.Widget("mobile_orderdetails_page_afterproducts")
        <div class="total-info">
            <table class="cart-total">
                <tbody>
                    <tr>
                        <td class="cart-total-left">
                            <span class="nobr">
                                @T("Order.SubTotal"):
                            </span>
                        </td>
                        <td class="cart-total-right">
                            <span class="nobr">
                                @Model.OrderSubtotal
                            </span>
                        </td>
                    </tr>
                    @if (!string.IsNullOrEmpty(Model.OrderSubTotalDiscount))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @T("Order.SubTotalDiscount"):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderSubTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.IsShippable)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @T("Order.Shipping"):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderShipping
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @T("Order.PaymentMethodAdditionalFee"):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.PaymentMethodAdditionalFee
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
                    {
                        foreach (var taxRate in Model.TaxRates)
                        {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @string.Format(T("Order.TaxRateLine").Text, taxRate.Rate):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @taxRate.Value
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.DisplayTax)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @T("Order.Tax"):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.Tax
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.OrderTotalDiscount))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @T("Order.TotalDiscount"):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.GiftCards.Count > 0)
                    {
                        foreach (var gc in Model.GiftCards)
                        {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @string.Format(T("Order.GiftCardInfo").Text, gc.CouponCode):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @gc.Amount
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.RedeemedRewardPoints > 0)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <span class="nobr">
                                    @string.Format(T("Order.RewardPoints").Text, Model.RedeemedRewardPoints):
                                </span>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.RedeemedRewardPointsAmount
                                </span>
                            </td>
                        </tr>
                    }
                    <tr>
                        <td class="cart-total-left">
                            <span class="nobr">
                                @T("Order.OrderTotal"):
                            </span>
                        </td>
                        <td class="cart-total-right">
                            <span class="nobr">
                                <strong>
                                    @Model.OrderTotal
                                </strong> 
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        @if (Model.Shipments.Count > 0)
        {
            <div class="section-title">
                @T("Order.Shipments")
            </div>                
            <ul data-role="listview" data-inset="true" data-filter="false" data-theme="c">
                @foreach (var item in Model.Shipments)
                {      
                    <li>
                        <div class="shipments-box">
                            <div>@T("Order.Shipments.ID"): @item.Id.ToString()</div>
                            <div>@T("Order.Shipments.TrackingNumber"): @item.TrackingNumber</div>
                            <div>@T("Order.Shipments.ShippedDate"):
                                @if (item.ShippedDate.HasValue)
                                {
                                    @item.ShippedDate.Value.ToString("D")
                                }
                                else
                                {
                                    @T("Order.Shipments.ShippedDate.NotYet")
                                }
                            </div>
                            <div>@T("Order.Shipments.DeliveryDate"):
                                @if (item.DeliveryDate.HasValue)
                                {
                                    @item.DeliveryDate.Value.ToString("D")
                                }
                                else
                                {
                                    @T("Order.Shipments.DeliveryDate.NotYet")
                                }
                            </div>
                            <div>
                                <a href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })">@T("Order.Shipments.ViewDetails")</a>
                            </div>
                        </div>
                    </li>
                }
            </ul>
        }
        @if (Model.OrderNotes.Count > 0)
        {
            <div class="section-title">
                @T("Order.Notes")
            </div>                
            <ul data-role="listview" data-inset="true" data-filter="false">
                @foreach (var item in Model.OrderNotes)
                {      
                    <li>
                        <div class="ordernotes-box">
                            <div>@T("Order.Notes.CreatedOn"): @item.CreatedOn.ToString()</div>
                            <div>@T("Order.Notes.Note"): @Html.Raw(item.Note)</div>
                            @if (item.HasDownload)
                            {
                                <div class="download"><a href="@Url.RouteUrl("GetOrderNoteFile", new { ordernoteid = item.Id })">@T("Order.Notes.Download")</a></div>
                            }
                        </div>
                    </li>
                }
            </ul>
        }
        @Html.Widget("mobile_orderdetails_page_bottom")
    </div>
</div>
